import React, { Component } from 'react';
import C from '../1_setState'
import './index.css'

export default class Parent extends Component {
    render() {
        return (
          <div className="parent">
            <h3>我是Parent组件</h3>
            <A render={(carName)=><B carName={carName}/>}/>
            <A render={(carName)=><C carName={carName}/>}/>
          </div>
        );
      }
}

class A extends Component {
    state = {
        carName: "奥拓"
    }
    render() {
        const {carName} = this.state
        console.log(this.props)
        return (
          <div className="child">
            <h3>我是A组件</h3>
            {this.props.render(carName)}
          </div>
        );
      }
}

class B extends Component {
    render() {
        return (
          <div className="grand">
            <h3>我是B组件,车名为：{this.props.carName}</h3>
          </div>
        );
      }
}
